package demo3;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/redirectB")
public class RedirectServletB extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 获取重定向的URL参数
        String orderId = request.getParameter("orderId");

        // 2. 直接写响应（无工具类）
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.write("<html><body>");
        out.write("<h3>重定向结果页</h3>");
        out.write("<p>订单ID：" + orderId + "</p>");
        out.write("<p>地址栏路径：" + request.getRequestURI() + "</p>");
        out.write("</body></html>");
        out.close();
    }
}

